<?php

namespace app\adminmini\service;

use app\adminmini\model\Package;
use think\facade\Db;

class PackageService extends BaseService
{
    public function __construct()
    {
        $this->model = new Package();
    }

    /**
     * @return array
     */
    public function getList()
    {
        $param = request()->param();

        // 查询条件
        $map = [];


        // 名称
        $name = isset($param['name']) ? trim($param['name']) : '';
        if ($name) {
            $map[] = ['name', 'like', "%{$name}%"];
        }
        $map[] = ['mark', '=', 1];
        $map[] = ['store_id', '=', $this->userId()];
        return parent::getList($map); // TODO: Change the autogenerated stub


    }

    public function edit()
    {
        $data = request()->param();
        $data['store_id'] = $this->userId();
        $list = Db::name('customer_course')
            ->where('store_id',$this->userId())
            ->select();
        foreach ($list as $k=>$v){
            cache('course'.$v['id'],false);
        }
        $data['update_time']=time();

        return parent::edit($data); // TODO: Change the autogenerated stub
    }
}